git-remote-annex enableremote to support readonly webdav
authorJoey Hess <joeyh@joeyh.name>
Tue, 7 Jan 2025 19:57:20 +0000 (15:57 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 7 Jan 2025 19:57:38 +0000 (15:57 -0400)
* Allow enableremote of an existing webdav special remote that has
  read-only access.
* git-remote-annex: Use enableremote rather than initremote.

CHANGELOG
CmdLine/GitRemoteAnnex.hs
Remote/WebDAV.hs
doc/special_remotes/webdav/comment_24_6c16a7c9abb257be4d046e27e11bacdf._comment
doc/todo/Read-only_support_for_webdav/comment_1_1fd87a5ab19a81a1b094efea7e70e581._comment [new file with mode: 0644]

index b401848477537053fffb5ef05ddb78ba713185be..70c26b518b4a561dd129f074b68d49e4668cd420 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,9 @@ git-annex (10.20250103) UNRELEASED; urgency=medium
   * Avoid verification error when addurl --verifiable is used
     with an url claimed by a special remote other than the web.
   * Fix installation on Android.
+  * Allow enableremote of an existing webdav special remote that has
+    read-only access.
+  * git-remote-annex: Use enableremote rather than initremote.
 
  -- Joey Hess <id@joeyh.name>  Fri, 03 Jan 2025 14:30:38 -0400
 
index ef1801dd9492fd1098716b8a6494cb5cabe7c421..da2a61b34b6f23a81ec2e232f8a89a01fbbb9849 100644 (file)
@@ -586,14 +586,15 @@ withSpecialRemote cfg@(SpecialRemoteConfig {}) sab a = case specialRemoteName cf
        Nothing -> specialRemoteFromUrl sab inittempremote
   where
        -- Initialize a new special remote with the provided configuration
-       -- and name.
+       -- and name. This actually does a Remote.Enable, because the
+       -- special remote has already been initialized somewhere before.
        initremote remotename = do
                let c = M.insert SpecialRemote.nameField (Proposed remotename) $
                        M.delete (Accepted "config-uuid") $
                        specialRemoteConfig cfg
                t <- either giveup return (SpecialRemote.findType c)
                dummycfg <- liftIO dummyRemoteGitConfig
-               (c', u) <- Remote.setup t Remote.Init (Just (specialRemoteUUID cfg)) 
+               (c', u) <- Remote.setup t (Remote.Enable c) (Just (specialRemoteUUID cfg)) 
                        Nothing c dummycfg
                        `onException` cleanupremote remotename
                Logs.Remote.configSet u c'
index d9984d338771ee81d94aab258368da1bb3bea703..aaf8b8f05934546d811c99a161328559ed143c95 100644 (file)
@@ -137,7 +137,9 @@ webdavSetup ss mu mcreds c gc = do
        (c', encsetup) <- encryptionSetup c gc
        pc <- either giveup return . parseRemoteConfig c' =<< configParser remote c'
        creds <- maybe (getCreds pc gc u) (return . Just) mcreds
-       testDav url creds
+       case ss of
+               Init -> testDav url creds
+               _ -> noop
        gitConfigSpecialRemote u c' [("webdav", "true")]
        c'' <- setRemoteCredPair ss encsetup pc gc (davCreds u) creds
        return (c'', u)
index 094399f6501cc14a5aba84555079dfab61fc4bf6..0b305c38a0c0e7e1bcd450bd774698a90dccfdaf 100644 (file)
@@ -1,10 +1,9 @@
 [[!comment format=mdwn
  username="joey"
- subject="""comment 24"""
- date="2023-06-20T17:25:27Z"
+ subject="""Re: read-only webdav access"""
+ date="2025-01-07T18:51:26Z"
  content="""
-httpalso now supports chunking. So I think there's no need to add readonly
-support to webdav, probably. But if you disagree, I do think it would be
-possible to add. Just probably not useful.. after all webdav minus writing
-is little different than http. If you disagree, open a [[todo]].
+Update: Since I posted this comment, enableremote of an existing webdav
+special remote has been made to work even if you cannot write to it. So
+there is no need to use httpalso and no need for a readonly=true.
 """]]
diff --git a/doc/todo/Read-only_support_for_webdav/comment_1_1fd87a5ab19a81a1b094efea7e70e581._comment b/doc/todo/Read-only_support_for_webdav/comment_1_1fd87a5ab19a81a1b094efea7e70e581._comment
new file mode 100644 (file)
index 0000000..063f088
--- /dev/null
@@ -0,0 +1,25 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2025-01-07T18:51:26Z"
+ content="""
+I'm not sure I'd trust an old comment of mine to reflect whether httpalso
+supports http authentication. From what I can see, without trying it, it
+will use git-credential to prompt for password when receiving a 401
+response, the same as all other parts of git-annex that download urls
+do nowadays.
+
+Re git-remote-annex, I see your point though. Since it does set up the
+remote when cloning, and webdav remote setup calls involves creating and
+deleting a test file, the user needs write access currently. (Whether that
+test file is worth it doing at all, I'm on the fence about. It seemed like
+a good idea way back when.)
+
+I think that, rather than needing readonly=true, enableremote of a webdav
+special remote should just assume it exists and not test write access to
+it. Then it will work with readonly access. I've implemented that.
+
+And I've made git-remote-annex on git clone do an enableremote, rather than
+an initremote. That should make it work with a readonly webdav special
+remote.
+"""]]